package com.xgst.runningmanager.http.api

import com.blankj.utilcode.util.TimeUtils
import com.hjq.http.annotation.HttpHeader
import com.hjq.http.annotation.HttpRename
import com.hjq.http.config.IRequestApi
import com.hjq.http.config.IRequestServer
import com.xgst.lib.utils.Sha1Utils
import com.xgst.runningmanager.constant.RongKey

class RongLoginAPI:IRequestApi,IRequestServer {
    private val nowMills = TimeUtils.getNowMills()

    override fun getHost(): String {
        return "http://api-cn.ronghub.com"
    }

    override fun getApi(): String {
        return "/user/getToken.json"
    }

    private var userId: String? = null
    private val name = "xgst"
    private val portraitUri = "http://www.baidu.com"

    fun setUserId(userId: String?): RongLoginAPI {
        this.userId = userId
        return this
    }

    @HttpHeader
    @HttpRename(value = "RC-App-Key")
    private val appKey: String = RongKey.RONG_KEY

    @HttpHeader
    @HttpRename(value = "RC-Nonce")
    private val nonce = "84654123854"

    @HttpHeader
    @HttpRename(value = "RC-Timestamp")
    private val timestamp = nowMills.toString() + ""

    @HttpHeader
    @HttpRename(value = "RC-Signature")
    private val signature: String =
        Sha1Utils.getSha1(RongKey.RONG_SECRET + "84654123854" + nowMills)

}